using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
    [Table("Template", "", "Wicresoft.Messages.ConnectionString")]
    public class Template : Info
    {
        #region SQL column name consts
        public const string SQLCOL_TEMPLATEID = "TemplateID";
        public const string SQLCOL_DEVICEID = "DeviceID";
        public const string SQLCOL_TEMPLATENAME = "TemplateName";
        public const string SQLCOL_ISDEFAULT = "IsDefault";
        public const string SQLCOL_TEXTTEMPLATE = "TextTemplate";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Template() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Template(Guid TemplateID)
        {
            this.TemplateID = TemplateID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            TemplateID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_TEMPLATEID]);
            DeviceID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_DEVICEID]);
            TemplateName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_TEMPLATENAME]);
            IsDefault = (bool)ObjectType.BooleanTypeHelper.Read(row[SQLCOL_ISDEFAULT]);
            TextTemplate = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_TEXTTEMPLATE]);
        }

        #region Properties
        #region Property <Guid> TemplateID
        [Property("TemplateID", 16, SqlDbType.UniqueIdentifier, false, true)]
        public Guid TemplateID
        {
            get { return _TemplateID; }
            set { _TemplateID = value; }
        }
        private Guid _TemplateID = Guid.Empty;
        #endregion

        #region Property <int> DeviceID
        [Property("DeviceID", 4, SqlDbType.Int, false, false)]
        public int DeviceID
        {
            get { return _DeviceID; }
            set { _DeviceID = value; }
        }
        private int _DeviceID = int.MinValue;
        #endregion

        #region Property <string> TemplateName
        [Property("TemplateName", 100, SqlDbType.NVarChar, false, false)]
        public string TemplateName
        {
            get { return _TemplateName; }
            set { _TemplateName = value; }
        }
        private string _TemplateName = null;
        #endregion

        #region Property <bool> IsDefault
        [Property("IsDefault", 1, SqlDbType.Bit, false, false)]
        public bool IsDefault
        {
            get { return _IsDefault; }
            set { _IsDefault = value; }
        }
        private bool _IsDefault = false;
        #endregion

        #region Property <string> TextTemplate
        [Property("TextTemplate", 2147483646, SqlDbType.NText, false, false)]
        public string TextTemplate
        {
            get { return _TextTemplate; }
            set { _TextTemplate = value; }
        }
        private string _TextTemplate = null;
        #endregion
        #endregion




    }
}
